package com.example.dobs.demo.flink.io.flatten;

import com.google.protobuf.Message;
import mypackage.Message.Book;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class BookParser extends Parser<FlattenedBook> implements Serializable {

    @Override
    public List<FlattenedBook> parse(Message msg) {
        Book book = (Book) msg;
        List<FlattenedBook> results = new ArrayList<>();

        FlattenedBook flattenedBook = FlattenedBook.builder()
                .author(book.getAuthor())
                .year(book.getYear())
                .title(book.getTitle())
                .build();
        results.add(flattenedBook);
        return results;
    }
}
